// 导入express
const express = require('express')
// 使用服务器的实例对象
const app = express()
// 导入并配置cors中间件 跨域
const cors = require('cors')
app.use(cors())
// 解析数据 注释掉 不然后面更改传输限制无效
app.use(express.json(),express.urlencoded({ extended: false }))
// 改变前端上传文件大小受限问题 之前接收base64，但数据库无法存储，后来改成前端传blob所以不需要更改大小限制
// var bodyParser = require('body-parser');
// app.use(bodyParser.json({ limit: '5000000000kb' }));
// app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
// 导入并使用路由模块
// 小程序端
const resultRouter = require('./router/result')
const goodsRouter = require('./router/goods')
const goodsDetailRouter = require('./router/goodsDetail')
const getTokenRouter = require('./router/getToken')
const creatOrderRouter = require('./router/creatOrder')
const payOkRouter = require('./router/payOk')
const checkOrderRouter = require('./router/checkOrder')
const forumInfoRouter = require('./router/forumInfo')
const addInterest = require('./router/addInterest')
const checkInterest = require('./router/checkInterest')
const deleteInterest = require('./router/deleteInterest')
const interestPage = require('./router/interestPage.js')
const addForum = require('./router/addForum.js')
const showMyForum = require('./router/showMyForum.js')
const deleteForum = require('./router/deleteForum.js')
const buyGoods = require('./router/buyGoods.js')
const feedBack = require('./router/feedBack.js')
// 后台管理端
const login = require('./router/login')
const vgoods = require('./router/vgoods')
const deleteGoods=require('./router/deleteGoods')
const addGoods = require('./router/addGoods')
const getOrders=require('./router/getOrders')
const deliverGoods=require('./router/deliverGoods')
// 注册路由模块
// 微信小程序端
app.use('/api',resultRouter)
app.use('/api',goodsRouter)
app.use('/api',goodsDetailRouter)
app.use('/api',getTokenRouter)
app.use('/api',creatOrderRouter)
app.use('/api',payOkRouter)
app.use('/api',checkOrderRouter)
app.use('/api',forumInfoRouter)
app.use('/api',addInterest)
app.use('/api',checkInterest)
app.use('/api',deleteInterest)
app.use('/api',interestPage)
app.use('/api',addForum)
app.use('/api',showMyForum)
app.use('/api',deleteForum)
app.use('/api',buyGoods)
app.use('/api',feedBack)
// 后台管理端
app.use('/api',login)
app.use('/api',vgoods)
app.use('/api',deleteGoods)
app.use('/api',addGoods)
app.use('/api',getOrders)
app.use('/api',deliverGoods)
// 启动服务器
app.listen(3007,'192.168.1.135',()=>{
    console.log('api server running');
})
